home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / image_SepiaTone.fx < prev    next >
Text File  |  2004-04-19  |  3KB  |  95 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. // Desc
  5. string desc : Description = "Image shader, ktery meni zobrazeni na sepia tone.";
  6. // Shader type phase
  7. string type : Type = "image";
  8. //---------------------------------------------------------------------------
  9. // Constant for luminance calculation
  10. const float4 cLum = {0.3f, 0.59f, 0.11f, 1.f};
  11. //---------------------------------------------------------------------------
  12. // Render target texture
  13. texture RT : RenderTargetFSMap;
  14. // Sepia tone
  15. texture1D Sepia 
  16. <
  17.     string file = "Sepia1D";
  18. >;
  19. //---------------------------------------------------------------------------
  20. sampler sRT = sampler_state
  21. {
  22.     Texture = <RT>;
  23.     MinFilter = POINT;
  24.     MagFilter = POINT;
  25.     AddressU = CLAMP;
  26.     AddressV = CLAMP;
  27. };
  28. sampler sSepia = sampler_state
  29. {
  30.     Texture = <Sepia>;
  31.     MinFilter = LINEAR;
  32.     MagFilter = LINEAR;
  33.     AddressU = CLAMP;
  34. };
  35. //---------------------------------------------------------------------------
  36. // Pixel shader
  37. float4 PS20(float2 uv: TEXCOORD0) : COLOR
  38. {
  39.     float4 c = .5;
  40.     float4 currFrameSample;
  41.     float4 currFrameSampleYIQ;
  42.  
  43.     float4x4 YIQMatrix = { 0.299,  0.587,  0.114,0, 
  44.                            0.596, -0.275, -0.321,0, 
  45.                            0.212, -0.523,  0.311,0,
  46.                            0,0,0,0};
  47.     
  48.     float4x4 inverseYIQ ={ 1.0000000000000000000, .95568806036115671171,  .61985809445637075388,  0,
  49.                            1.0000000000000000000, -.27158179694405859326, -.64687381613840131330, 0,
  50.                            1.0000000000000000000, -1.1081773266826619523, 1.7050645599191817149,  0,
  51.                            0,0,0,0 };
  52.     // get sample
  53.     currFrameSample = tex2D(sRT, uv);
  54.     
  55.     // convert to YIQ space
  56.     currFrameSampleYIQ = mul(YIQMatrix , currFrameSample);
  57.  
  58.     currFrameSampleYIQ.y = 0.2;    // convert YIQ color to sepia tone
  59.     currFrameSampleYIQ.z = 0.0;
  60.  
  61.     // convert back to RGB    
  62.     c = mul(inverseYIQ, currFrameSampleYIQ);
  63.     return c;
  64. }
  65. //---------------------------------------------------------------------------
  66. float4 PS14(float2 uv: TEXCOORD0) : COLOR
  67. {
  68.     float4 currFrameSample = tex2D(sRT, uv);
  69.     float fdot = currFrameSample.x*cLum.x + currFrameSample.y*cLum.y + currFrameSample.z*cLum.z;
  70.     // read in transfer 
  71.     return tex1D(sSepia, fdot);
  72. }
  73. //---------------------------------------------------------------------------
  74. technique vs0_ps20
  75. {
  76.     pass p0
  77.     {
  78.            ZEnable = false;
  79.         ZWriteEnable = false;
  80.    
  81.         PixelShader  = compile ps_2_0 PS20();
  82.     }
  83. }
  84. //---------------------------------------------------------------------------
  85. technique vs0_ps14
  86. {
  87.     pass p0
  88.     {
  89.            ZEnable = false;
  90.         ZWriteEnable = false;
  91.    
  92.         PixelShader  = compile ps_1_4 PS14();
  93.     }
  94. }
  95. //---------------------------------------------------------------------------